# -*- coding: utf-8 -*- 

from levin.ordereddict import OrderedDict

## def _(a):
##     return a

class DicList(list):
    def __init__(self, *args):
        list.__init__(self)
        for i in args:
            self.append(i)
            setattr(self, i[0], i[1])
    def __getitem__(self,n):
        try:
            getattr(self,n)
        except:
            for u,v in self:
                if u==n :
                    return v
            
        raise KeyError
    
class AttrDict(OrderedDict):
    def __init__(self, *args, **kwargs):
        OrderedDict.__init__(self, *args, **kwargs)
    def __getattr__(self, name):
        if name.startswith('_'):
            return self.__getattribute__(name)
        else:
            self[name]

    def __setattr__(self, name ,value):
        if name.startswith('_'):
            self.__dict__[name]=value
        else:
            self[name] = value

## class TastingAttribute(object):
##     def __init__(self, name, title):
class OrderedTastingAtt_t(dict):
    visual = DicList( ('visual_color' , _("Color") ),    
                      ('visual_viscosity' , _("Viscosity") ),
                      ('visual_shine' , _("Shine") ),
                      ('visual_more' , _("Visual aspects") ),
                      )
    visual_desc = _("Visual aspects")
    
    smell  =  DicList( ('smell_first' , _("First smell") ),
                       ('smell_strength' , _("Strength") ),
                       ('smell_aroma' , _("Aromas") ),
                       ('smell_more' , _("Smelling aspects") ),
                       )
    smell_desc = _("Smelling aspects")


    taste = DicList( ('taste_start' , _('Start') ),
                      ('taste_balance' , _('Balance') ),
                      ('taste_body' , _('Body') ),
                      ('taste_final' , _('Final') ),
                      ('taste_length' , _('Lenght') ),
                      ('taste_more' , _('Tasting aspects') ),
                      )
    taste_desc = _("Tasting aspects")


    comment = _("Other Comments")


    other_ = _(" (others)")

    def __init__(self):
        super(OrderedTastingAtt_t,self).__init__()
        for a in ['visual', 'smell','taste']:
            l = getattr(self,a)
            self[a] = l
            for att,v in l:
                self[att] = v
        self['comment'] = self.comment
            
    def iterattributes(self):
        for a in ['visual', 'smell','taste']:
            yield a, self[a]
    def iterAll(self):
        for ag, d in self.iterattributes():
            for a,ad in d:
                yield a,ad
        yield 'comment', self.comment

    def iterBasicAtt(self):
        for a in ['visual_more', 'smell_more','taste_more','comment'] :
            yield a, self[a]

    

OrderedTastingAtt = OrderedTastingAtt_t()    

TastingDescriptions = {
    'visual_color': [ _("violet"), _("purple"), _("carmine lake"), _("amaranth"), _("purple"), _("crimson"), _("ruby"), _("vermilion"), _("madder"), _("mahogany"), _("orange"), _("brick-red"), _("ocher") ], #violet, pourpre, laque carminée, amarante, grenat, carmin, rubis, vermillon, garance, acajou, orangée, tuilée, ocre ],
    'visual_viscosity': [],
    'visual_shine': [_("crystalline"), _("shiny"), _("sparkling"), _("dull"), _("off"),], #cristallin, brillant, éclatant ou au contraire mat, terne, éteint
    'visual_more': [_("limpid"), _("clear"), _("transparent"), _("loaded"), _("troubled"), _("cloudy"),], # limpide, clair, transparent chargé, troublé, voilé
    
    
    'smell_first': [],
    'smell_strength': [],
    'smell_aroma': [_("animal"), _("balsamic"), _("woody"), _("chemical"), _("ethereal"), _("spicy"), _("empyreumatic"), _("floral"), _("fruity"), _("vegetable"), _("primary"), _("secondary"), _("tertiary"),],
    'smell_more': [],

    
    'taste_start': [],
    'taste_balance': [_("sweet"), _("acid"), _("alcohol"), ], 
    'taste_body': [],
    'taste_final': [],
    'taste_length': [],
    'taste_more': [],


    }

#TastingDescriptions['visual_more'] = sum( [TastingDescriptions[i] for i in ['visual_color', 'visual_shine', 'visual_viscosity'] ] , [])
TastingDescriptions['visual_more'] = [TastingDescriptions[i] for i in ['visual_color', 'visual_shine', 'visual_more'] ]

#TastingDescriptions['smell_more'] = sum( [TastingDescriptions[i] for i in ['smell_first', 'smell_strength', 'smell_aroma'] ] , [])
TastingDescriptions['smell_more'] =  [TastingDescriptions[i] for i in ['smell_first', 'smell_strength', 'smell_aroma'] ] 

#TastingDescriptions['taste_more'] = sum( [TastingDescriptions[i] for i in ['taste_start', 'taste_balance', 'taste_body', 'taste_final', 'taste_length'] ] , [])
TastingDescriptions['taste_more'] =  [TastingDescriptions[i] for i in ['taste_start', 'taste_balance', 'taste_body', 'taste_final', 'taste_length'] ]


def allTastingAtt():
    for t, d in OrderedTastingAtt.iteritems():
        for k,v in d.iteritems():
            yield k,v

